package book.userservice.imp;

import book.userdao.UserDao;
import book.userentity.User;
import book.userservice.UserService;
import com.nf.Annotation.Autowired;
import com.nf.Annotation.ClassAnnotation;
import com.nf.Annotation.Scope;

public class UserServiceImpl implements UserService {
    @Autowired("userDaoImpl")
    private UserDao userDao;
    /**
     * @see :通过一个User对象来注册用户
     */
    public boolean insertUser(User user){
        boolean flag=false;
        int i = userDao.insertUser(user);
        if(i!=0){
            flag=true;
        }
        return flag;
    }
    /**
     * @see :通过手机号查询出用户 判断是否登录成功
     */
    public String judgeLogin(User user){
        String flag="";
        User userResult = userDao.selectPhoneUser(user.getUserPhone());
        if(userResult==null){
            flag="账号错误";
        }else{
            String password = user.getUserPassword();
            String passwordResult = userResult.getUserPassword();
            if(!password.equals(passwordResult)){
                flag="密码错误";
            }
        }
        return flag;
    }
    /**
     * @see :通过一个User对象来修改用户信息
     */
    public int updateUser(User user){
        int i = userDao.updateUser(user);
        return i;
    }
}
